package com.example.jedis_pool.demo;

import com.example.jedis_pool.jedis_config.Config;
import redis.clients.jedis.Jedis;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Random {


    private static Jedis jedis= Config.JedisPool().getResource();

    public static void main(String[] args) {

       String num= new Random().randomPop("key-name",100);
       System.out.println("随机数为："+num);
        //关闭连接
        jedis.close();

    }

    public String randomPop(String keyname, int num){

        random(keyname, num);
        return jedis.spop(keyname);


    }

    public void random(String keyname, int num){
        for (int i=1;i<=num;i++){

             jedis.sadd(keyname,Integer.toString(i));

        }
        System.out.println(jedis.scard(keyname));

    }
}
